package com.example.smokealarm.controller;

import com.example.smokealarm.model.RpiData;
import com.example.smokealarm.service.RpiDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class RpiDataController {
    @Autowired
    private RpiDataService rpiDataService;

    @GetMapping("/add")
    public RpiData addRpiData(@RequestBody RpiData rpiData) {
        return rpiDataService.saveRpiData(rpiData);
    }


    //detail
    @GetMapping("/home/smokedata")
    public List<RpiData> displaySmokeData() {
        return rpiDataService.getRecentData(12); // 获取近12小时的数据
    }

    @GetMapping("/display")
    public List<RpiData> displayRpiData() {
        return rpiDataService.getRecentData(12); // 获取近12小时的数据
    }

}